package cn.fxl.scheduledmessage;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.common.RemotingHelper;

/**
 * 消息发送
 */
public class SyncProducer {
    public static void main(String[] args) throws Exception {
        // 实例化消息生产者Producer
        DefaultMQProducer producer = new DefaultMQProducer("please_rename_scheduledmessage_group_name");
        producer.setNamesrvAddr("localhost:9876");
        producer.start();
        Message message = new Message("scheduledmessageTest", "TagA", "嘿嘿嘿".getBytes(RemotingHelper.DEFAULT_CHARSET));
        message.setDelayTimeLevel(2);
        SendResult send = producer.send(message);
        System.out.println("发送完毕，结果: "+send);
        producer.shutdown();
    }
}
